home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / ibm / asref.arc / ASREF.MAN
Text File  |  1989-04-16  |  77KB  |  2,103 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                                     MOTOROLA
  11.  
  12.                                     FREEWARE
  13.  
  14.                              8-BIT CROSS ASSEMBLERS
  15.  
  16.                                   USER'S MANUAL
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.                                      EDITED BY
  53.  
  54.                                    KEVIN ANDERSON
  55.  
  56.                              FIELD APPLICATIONS ENGINEER
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                            TABLE OF CONTENTS
  63.  
  64. CHAPTER 1.........................................................  1
  65.  
  66.      1.1   INTRODUCTION ..........................................  1
  67.      1.2   ASSEMBLY LANGUAGE .....................................  1
  68.      1.3   OPERATING ENVIRONMENT .................................  2
  69.      1.4   ASSEMBLER PROCESSING ..................................  2
  70.  
  71. CHAPTER 2 ........................................................  3
  72.  
  73.      2.1   INTRODUCTION ..........................................  3
  74.      2.2   SOURCE STATEMENT FORMAT ...............................  3
  75.           2.2.1   Label Field ....................................  3
  76.           2.2.2   Operation Field ................................  4
  77.           2.2.3   Operand Field ..................................  4
  78.                2.2.3.1  M6800/6801 Operand Syntax ................  5
  79.                2.2.3.2  M6800/M68HC04 Operand Syntax .............  5
  80.                2.2.3.3  M6805/M68HC05 Operand Syntax .............  5
  81.                2.2.3.4  M6809 Operand Syntax .....................  5
  82.                2.2.3.5  M68HC11 Operand Syntax ...................  6
  83.                2.2.3.6  Expressions ..............................  6
  84.                2.2.3.7  Operators ................................  7
  85.                2.2.3.8  Symbols ..................................  7
  86.                2.2.3.9  Constants ................................  7
  87.           2.2.4   Comment Field ..................................  8
  88.      2.3   ASSEMBLER OUTPUT ......................................  9
  89.  
  90. CHAPTER 3 - RUNNING THE ASSEMBLERS ...............................  10
  91.  
  92.      3.1   ASSEMBLER INVOCATION ..................................  10
  93.      3.2   ERROR MESSAGES ........................................  11
  94.  
  95. CHAPTER 4 - ASSEMBLER DIRECTIVES .................................  12
  96.  
  97.      4.1   INTRODUCTION ..........................................  12
  98.      4.2   BSZ - BLOCK STORAGE OF ZEROS ..........................  12
  99.      4.3   EQU - EQUATE SYMBOL TO A VALUE ........................  13
  100.      4.4   FCB - FORM CONSTANT BYTE ..............................  13
  101.      4.5   FCC - FORM CONSTANT CHARACTER STRING ..................  13
  102.      4.6   FDB - FROM DOUBLE BYTE CONSTANT .......................  13
  103.      4.7   FILL - FILL MEMORY ....................................  14
  104.      4.8   OPT - ASSEMBLER OUTPUT OPTIONS ........................  14
  105.      4.9   ORG - SET PROGRAM COUNTER TO ORIGIN ...................  14
  106.      4.10   PAGE - TOP OF PAGE ...................................  15
  107.      4.11   RMB - RESERVE MEMORY BYTES ...........................  15
  108.      4.12   ZMB - ZERO MEMORY BYTES ..............................  15
  109.  
  110. APPENDIX A - CHARACTER SET .......................................  16
  111.  
  112. APPENDIX B - ADDRESSING MODES ....................................  18
  113.  
  114.      B.1   M6800/M6801 ADDRESSING MODES ..........................  18
  115.      B.2   M6804/68HC04 ADDRESSING MODES .........................  19
  116.      B.3   M6805/68HC05 ADDRESSING MODES .........................  21
  117.  
  118.  
  119.  
  120.                                 i
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                            TABLE OF CONTENTS
  129.  
  130.      B.4   M6809 ADDRESSING MODES ................................  22
  131.      B.5   M68HC11 ADDRESSING MODES ..............................  26
  132.  
  133. APPENDIX C - DIRECTIVE SUMMARY ...................................  28
  134.  
  135. APPENDIX D - ASSEMBLER LISTING FORMAT ............................  29
  136.  
  137. APPENDIX E - S-RECORD INFORMATION ................................  30
  138.  
  139.      E.1   INTRODUCTION ..........................................  30
  140.      E.2   S-RECORD CONTENT ......................................  30
  141.      E.3   S-RECORD TYPES ........................................  30
  142.      E.4   S-RECORD EXAMPLE ......................................  31
  143.  
  144.                                    ii
  145.  
  146.  
  147.  
  148.  
  149.  
  150.                                CHAPTER 1
  151.                           GENERAL INFORMATION
  152.  
  153.  
  154. 1.1   INTRODUCTION
  155.  
  156. This is the user's reference manual for the  IBM-PC  hosted  Motorola 
  157. Freeware  8  bit  cross  assemblers.   It  details  the  features and 
  158. capabilities  of  the  cross   assemblers,   assembler   syntax   and 
  159. directives,  options,  and  listings.  It  is  intended as a detailed
  160. reference and an introduction  for  those  unfamiliar  with  Motorola 
  161. assembler   syntax  and  format.   Those  experienced  with  Motorola 
  162. assembler  products  may  wish  to  examine  the  file   ASSEMBLER.DOC 
  163. available  with  the  cross  assemblers,  which briefly describes the 
  164. differences  between  these  assemblers  and  earlier,  non-pc  based 
  165. versions.
  166.  
  167. Assemblers are programs that process assembly language source program 
  168. statements and translate them into executable machine language object 
  169. files.   A programmer writes his source program using any text editor 
  170. or word processor that can produce an ASCII text output.   With  some 
  171. word  processors  this is known as "non document" mode.  Non document 
  172. mode produces a  file  without  the  non-printable  embedded  control 
  173. characters that are used in document formatting.  (Caution: assembling 
  174. a file that has been formatted with embedded control  characters  may 
  175. produce assembler errors.  The solution is to convert the source file 
  176. to ASCII text.) Once the source code is written, the source  file  is 
  177. assembled by processing the file via the assembler.
  178.  
  179. Cross  assemblers  (such  as  the Motorola Freeware Assemblers) allow 
  180. source programs written and edited on  one  computer  (the  host)  to 
  181. generate  executable  code  for  another  computer (the target).  The 
  182. executable object file can then be downloaded and run on  the  target 
  183. system.   In  this  case  the host is an IBM-PC or compatible and the 
  184. target system is based on  a  Motorola  8-bit  microprocessor  (6800, 
  185. 6801, 6803, 6805, 68HC05, 6809, or 68HC11).
  186.  
  187. The  assemblers are the executable programs AS*.EXE where * is any of 
  188. 0, 1, 4, 5, 9, or  11  depending  on  which  microprocessor  you  are 
  189. writing  code  for.   The details of executing the assembler programs 
  190. are found in Chapter 3.  The assembly language format and syntax  for 
  191. the  various processors is very similar with slight variations due to 
  192. varied programming resources  (instructions,  addressing  modes,  and 
  193. registers). These variations are explained in Appendix B.
  194.  
  195.  
  196. 1.2 ASSEMBLY LANGUAGE
  197.  
  198. The symbolic language used to code source programs to be processed by 
  199. the  Assembler  is  called  assembly  language.  The  language  is  a 
  200. collection   of  mnemonic  symbols  representing:  operations  (i.e., 
  201. machine  instruction  mnemonics  or  directives  to  the  assembler), 
  202. symbolic names, operators, and special symbols. The assembly language 
  203. provides mnemonic operation codes for all machine instructions in the 
  204. instruction  set.  The  instructions are defined and explained in the 
  205. Programming Reference Manuals for  the  specific  devices,  available 
  206. from Motorola. The assembly language also contains mnemonic directives
  207.  
  208.  
  209.  
  210.                                    Freeware Assemblers User's Manual
  211.  
  212.  
  213. which  specify  auxiliary  actions  to be performed by the Assembler. 
  214. These directives are not always translated into machine language.
  215.  
  216.  
  217. 1.3   OPERATING ENVIRONMENT
  218.  
  219. These assemblers will run on  any  IBM-PC,  XT,  AT,  PS-2,  or  true 
  220. compatible.   The assemblers may be run off of a floppy disk drive or 
  221. they may be copied onto a hard drive for execution.  DOS 2.0 or later 
  222. is required.
  223.  
  224.  
  225. 1.4   ASSEMBLER PROCESSING
  226.  
  227. The  Macro  Assembler is a two-pass assembler. During the first pass, 
  228. the source program is read to develop the symbol  table.  During  the 
  229. second pass, the object file is created (assembled) with reference to 
  230. the table developed in pass one. It is during the  second  pass  that 
  231. the source program listing is also produced.
  232.  
  233. Each  source statement is processed completely before the next source 
  234. statement is read. As each  statement  is  processed,  the  Assembler 
  235. examines the label, operation code, and operand fields. The operation 
  236. code table is scanned for a match with a known  opcode.   During  the 
  237. processing  of  a  standard  operation  code  mnemonic,  the standard 
  238. machine code is inserted  into  the  object  file.  If  an  Assembler 
  239. directive is being processed, the proper action is taken.
  240.  
  241. Any  errors  that  are detected by the Assembler are displayed before 
  242. the actual line containing the error is printed. If no source listing 
  243. is  being  produced,  error  messages are still displayed to indicate 
  244. that the assembly process did not proceed normally.
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.                                  2
  270.  
  271.  
  272.  
  273.                                    Freeware Assemblers User's Manual
  274.  
  275.  
  276.                               CHAPTER 2 
  277.                    CODING ASSEMBLY LANGUAGE PROGRAMS
  278.  
  279.  
  280. 2.1   INTRODUCTION
  281.  
  282. Programs written in assembly language consist of a sequence of source 
  283. statements.  Each  source  statement  consists of a sequence of ASCII 
  284. characters ending with a carriage return.  Appendix A contains a list 
  285. of the supported character set.
  286.  
  287.  
  288. 2.2   SOURCE  STATEMENT FORMAT
  289.  
  290. Each  source statement may include up to four fields: a label (or "*" 
  291. for a comment line), an operation (instruction mnemonic or assembler 
  292. directive), an operand, and a comment.
  293.  
  294.  
  295. 2.2.1   Label Field
  296.  
  297. The  label field occurs as the first field of a source statement. The 
  298. label field can take one of the following forms:
  299.  
  300. 1. An asterisk  (*)  as  the  first  character  in  the  label  field 
  301. indicates  that  the  rest  of  the  source  statement  is a comment. 
  302. Comments are ignored by the Assembler, and are printed on the  source 
  303. listing only for the programmer's information.
  304.  
  305. 2.  A  white space  character  (blank  or  tab) as the first character 
  306. indicates that the label field is empty. The line has no label and is 
  307. not a comment.
  308.  
  309. 3.  A symbol character as the first character indicates that the line 
  310. has a label. Symbol characters are the upper or lower case letters a- 
  311. z,  digits  0-9,  and the special characters, period (.), dollar sign 
  312. ($), and underscore (_). Symbols consist of one to 15 characters, the 
  313. first  of  which  must be alphabetic or the special characters period 
  314. (.) or underscore (_).  All characters are significant and upper  and 
  315. lower case letters are distinct.
  316.  
  317. A  symbol  may  occur  only once in the label field. If a symbol does 
  318. occur more than once in a label field, then each  reference  to  that 
  319. symbol will be flagged with an error.
  320.  
  321. With  the exception of some directives, a label is assigned the value 
  322. of the program counter of the first byte of the instruction  or  data 
  323. being  assembled. The value assigned to the label is absolute. Labels 
  324. may optionally be ended with a colon (:).  If the colon is used it is 
  325. not  part  of the label but merely acts to set the label off from the 
  326. rest of the source line.   Thus  the  following  code  fragments  are 
  327. equivalent:
  328.  
  329.      here:  deca
  330.             bne here
  331.  
  332.                                  3
  333.  
  334.  
  335.                                    Freeware Assemblers User's Manual
  336.  
  337.  
  338.      here   deca
  339.             bne here
  340.  
  341. A  label  may  appear  on a line by itself.  The assembler interprets 
  342. this as set the value of the label equal to the current value of  the 
  343. program counter.
  344.  
  345. The  symbol  table  has  room  for  at least 2000 symbols of length 8 
  346. characters or less.  Additional characters up to 15  are  permissible 
  347. at  the  expense of decreasing the maximum number of symbols possible 
  348. in the table.
  349.  
  350.  
  351. 2.2.2   Operation Field
  352.  
  353. The operation field  occurs  after  the  label  field,  and  must  be 
  354. preceded  by  at  least one white space character. The operation field 
  355. must contain a legal opcode  mnemonic  or  an  assembler  directive.  
  356. Upper  case  characters  in  this  field  are converted to lower case 
  357. before being checked as a legal mnemonic.  Thus  'nop',  'NOP',  and 
  358. 'NoP'  are recognized as the same mnemonic. Entries in the operation 
  359. field may be one of two types:
  360.  
  361. Opcode. These correspond directly to the  machine  instructions.  The 
  362. operation  code  includes  any  register  name  associated  with  the 
  363. instruction.  These register names must not  be  separated  from  the 
  364. opcode  with  any  white space  characters.   Thus  'clra' means clear 
  365. accumulator A, but 'clr a' means clear memory location identified  by 
  366. the label 'a'.
  367.  
  368. Directive.  These  are special operation codes known to the Assembler 
  369. which control the assembly process rather than being translated  into 
  370. machine instructions.
  371.  
  372.  
  373. 2.2.3   Operand Field
  374.  
  375. The  operand  field's  interpretation is dependent on the contents of 
  376. the operation field. The operand field, if required, must follow  the 
  377. operation  field,  and  must  be  preceded by at least one white space 
  378. character. The operand field may contain a symbol, an expression,  or 
  379. a combination of symbols and expressions separated by commas.
  380.  
  381. The  operand  field  of  machine  instructions is used to specify the 
  382. addressing mode of the instruction, as well as  the  operand  of  the 
  383. instruction.   The  following  tables  summarize  the  operand  field 
  384. formats for the various processor families. (NOTE:  in  these  tables 
  385. parenthesis  "()"  signify  optional elements and angle brackets "<>" 
  386. denote an expression is inserted.  These syntax elements are  present 
  387. only  for clarification of the format and are not inserted as part of 
  388. the actual source program.  All other characters are significant  and 
  389. must be used when required.)
  390.  
  391.  
  392.  
  393.  
  394.                                  4
  395.  
  396.  
  397.                                    Freeware Assemblers User's Manual
  398.  
  399.  
  400. 2.2.3.1  M6800/6801 Operand Syntax
  401.  
  402. The format of the operand field for M6800/6801 instructions is:
  403.  
  404.      Operand Format           M6800/M6801 Addressing Mode
  405.      --------------           ---------------------------
  406.      no operand               accumulator and inherent
  407.      <expression>             direct, extended, or relative
  408.      #<expression>            immediate
  409.      <expression>,X           indexed
  410.  
  411. Details of the M6800/6801 addressing modes may be found in Appendix B.
  412.  
  413.  
  414. 2.2.3.2  M6804/68HC Operand Syntax
  415.  
  416. For the M6804/68HC04, the following operand formats exist:
  417.  
  418.      Operand Format                M6804/68HC04 Addressing Mode
  419.      --------------                ----------------------------
  420.      no operand                    accumulator and inherent
  421.      <expression>                  direct, extended, or relative
  422.      #<expression>                 immediate
  423.      <expression>                  bit set or clear
  424.      <expression>,<expression>     bit test and branch
  425.      [<x> or <y>]                  register indirect
  426.      <expression>,#<expression>    move indirect
  427.  
  428. Details of the M6804/68HC04 addressing modes may be found in Appendix
  429. B.
  430.  
  431.  
  432. 2.2.3.3  M6805/M68HC05 Operand Syntax
  433.  
  434. For the M6805/68HC05, the operand formats are:
  435.  
  436.      Operand Format                M6805/68HC05 Addressing Mode
  437.      --------------                ----------------------------
  438.      no operand                    accumulator and inherent
  439.      <expression>                  direct, extended, or relative
  440.      #<expression>                 immediate
  441.      <expression>,X                indexed
  442.      <expression>,<expression>     bit set or clear
  443.      <expression>,<expression>,<expression>     bit test and branch
  444.  
  445. Details of the M6805/68HC05 addressing modes may be found in Appendix
  446. B.
  447.  
  448.  
  449. 2.2.3.4  M6809 Operand Syntax
  450.  
  451. For the M6809, the following  operand formats are used:
  452.  
  453.  
  454.  
  455.  
  456.                                  5
  457.  
  458.  
  459.                                    Freeware Assemblers User's Manual
  460.  
  461.  
  462.      Operand Format           M6809 Addressing Mode
  463.      --------------           ---------------------
  464.      no operand               accumulator and inherent
  465.      <expression>             direct, extended, or relative
  466.      #<expression>            immediate
  467.      <expression>,X           indexed
  468.      <<expression>            forced direct
  469.      ><expression>            forced extended
  470.      <expression>]            extended indirect
  471.      <expression>,R           indexed
  472.      <<expression>,R          forced 8-bit offset indexed
  473.      ><expression>,R          forced 16-bit offset indexed
  474.      [<expression>,R]         indexed indirect
  475.      <[<expression>,R]        forced 8-bit offset indexed indirect
  476.      >[<expression>,R]        forced 16-bit offset indexed indirect
  477.      Q+                       auto increment by 1
  478.      Q++                      auto increment by 2
  479.      [Q++]                    auto increment indirect
  480.      -Q                       auto decrement by
  481.      --Q                      auto decrement by 2
  482.      [--Q]                    auto decrement indirect
  483.      W1,[W2,...,Wn]           immediate
  484.  
  485. where R is one of the registers PCR, S, U, X, or Y, and Q is one of
  486. the registers S, U, X, or Y.   Wi  (i=1 to n) is one of the symbols A,
  487. B, CC, D, DP, PC, S, U, X, or Y.
  488.  
  489. Details of the M6809 addressing modes may be found in Appendix B.
  490.  
  491.  
  492. 2.2.3.5  M68HC11 Operand Syntax
  493.  
  494. For the M68HC11, the following operand formats exist:
  495.  
  496.      Operand Format                M68HC11 Addressing Mode
  497.      --------------                -----------------------
  498.      no operand                    accumulator and inherent
  499.      <expression>                  direct, extended, or relative
  500.      #<expression>                 immediate
  501.      <expression>,X                indexed with X register
  502.      <expression>,Y                indexed with Y register
  503.      <expression> <expression>     bit set or clear
  504.      <expression> <expression> <expression>     bit test and branch
  505.  
  506. The  bit manipulation instruction operands are separated by spaces in 
  507. this case since the HC11  allows  bit  manipulation  instructions  on 
  508. indexed addresses.  Thus a ',X' or ',Y' may be added to the final two 
  509. formats above to form the indexed effective address calculation.
  510.  
  511. Details of the M68HC11 addressing modes  may be found in  Appendix  B.
  512. The operand fields of assembler directives are described in Chapter 4.
  513.  
  514.  
  515. 2.2.3.6  Expressions.   An  expression  is  a combination of symbols, 
  516. constants, algebraic operators, and parentheses.  The  expression  is 
  517. used to specify a value which is to be used as an operand.
  518.  
  519.                                 6
  520.  
  521.  
  522.                                    Freeware Assemblers User's Manual
  523.  
  524.  
  525. Expressions  may  consist of symbols, constants, or the character '*' 
  526. (denoting the current value of the program counter)  joined  together 
  527. by one of the operators: + - * / % & | ^ .
  528.  
  529.  
  530. 2.2.3.7  Operators.  The operators are the same as in c:
  531.  
  532.      +    add
  533.      -    subtract
  534.      *    multiply
  535.      /    divide
  536.      %    remainder after division
  537.      &    bitwise and
  538.      |    bitwise or
  539.      ^    bitwise exclusive or
  540.  
  541. Expressions are evaluated left to right and there is no provision for 
  542. parenthesized expressions.  Arithmetic is carried out in signed  twos
  543. complement integer precision (that's 16 bits on the IBM PC).
  544.  
  545.  
  546. 2.2.3.8  Symbols.   Each  symbol  is associated with a 16-bit integer 
  547. value which is used in place of  the  symbol  during  the  expression 
  548. evaluation.   The  asterisk  (*)  used  in  an expression as a symbol 
  549. represents the current value of the location counter (the first  byte 
  550. of a multi-byte instruction).
  551.  
  552.  
  553. 2.2.3.9  Constants.   Constants  represent quantities of data that do 
  554. not vary in value during the execution of a program.   Constants  may 
  555. be  presented  to  the  assembler  in  one  of five formats: decimal, 
  556. hexadecimal, binary, or octal, or ASCII.   The  programmer  indicates 
  557. the number format to the assembler with the following prefixes:
  558.  
  559.      $    HEX
  560.      %    BINARY
  561.      @    OCTAL
  562.      '    ASCII
  563.  
  564. Unprefixed  constants  are  interpreted  as  decimal.   The assembler 
  565. converts all constants to binary machine code and  are  displayed  in 
  566. the assembly listing as hex.
  567.  
  568. A  decimal constant consists of a string of numeric digits. The value 
  569. of a decimal constant must fall in the range 0-65535, inclusive.  The 
  570. following example shows both valid and invalid decimal constants:
  571.  
  572.      VALID     INVALID   REASON INVALID
  573.      -----     -------   --------------
  574.      12        123456    more than 5 digits
  575.      12345     12.3      invalid character
  576.  
  577. A  hexadecimal constant consists of a maximum of four characters from 
  578. the set of digits (0-9) and the upper case alphabetic letters  (A-F), 
  579. and is preceded by a dollar sign ($).  Hexadecimal constants must be
  580.  
  581.  
  582.                                  7
  583.  
  584.  
  585.                                    Freeware Assemblers User's Manual
  586.  
  587.  
  588. in  the  range $0000 to $FFFF. The following example shows both valid 
  589. and invalid hexadecimal constants:
  590.  
  591.      VALID     INVALID   REASON INVALID
  592.      -----     -------   --------------
  593.      $12       ABCD      no preceding "$"
  594.      $ABCD     $G2A      invalid character
  595.      $001F     $2F018    too many digits
  596.  
  597. A binary constant consists of a maximum of 16 ones or zeros  preceded 
  598. by  a  percent  sign (%).  The following example shows both valid and 
  599. invalid binary constants:
  600.  
  601.      VALID     INVALID             REASON INVALID
  602.      -----     -------             --------------
  603.      %00101    1010101             missing percent
  604.      %1        %10011000101010111  too many digits
  605.      %10100    %210101             invalid digit
  606.  
  607. An octal constant consists  of  a  maximum  of  six  numeric  digits, 
  608. excluding  the  digits 8 and 9, preceded by a commercial at-sign (@). 
  609. Octal constants must be in the ranges @0 to @177777.   The  following 
  610. example shows both valid and invalid octal constants:
  611.  
  612.      VALID     INVALID   REASON INVALID
  613.      -----     -------   --------------
  614.      @17634    @2317234  too many digits
  615.      @377      @277272   out of range
  616.      @177600   @23914    invalid character
  617.  
  618. A  single  ASCII  character can be used as a constant in expressions. 
  619. ASCII constants are preceded by a single quote  (').  Any  character, 
  620. including the single quote, can be used as a character constant.  The 
  621. following example shows both valid and invalid character constants:
  622.  
  623.      VALID     INVALID   REASON INVALID
  624.      -----     -------   --------------
  625.      '*        'VALID    too long
  626.  
  627. For the invalid case above the assembler will not indicate an  error. 
  628. Rather it will assemble the first character and ignore the remainder.
  629.  
  630.  
  631. 2.2.4   Comment Field
  632.  
  633. The last field of an Assembler source statement is the comment field. 
  634. This field is optional and is only printed on the source listing  for 
  635. documentation  purposes.  The  comment  field  is  separated from the 
  636. operand field (or from the operation field if no operand is required) 
  637. by  at  least one white space character. The comment field can contain 
  638. any printable ASCII characters.
  639.  
  640.  
  641.  
  642.                                  8
  643.  
  644.  
  645.  
  646.                                    Freeware Assemblers User's Manual
  647.  
  648.  
  649. 2.3   ASSEMBLER OUTPUT
  650.  
  651. The Assembler output includes  an  optional  listing  of  the  source 
  652. program  and an object file which is in the Motorola S Record format. 
  653. Details of the S Record format may  be  found  in  Appendix  E.   The 
  654. Assembler  will normally suppress the printing of the source listing. 
  655. This condition, as well as others,  can  be  overridden  via  options 
  656. supplied on the command line that invoked the Assembler.
  657.  
  658. Each  line  of  the  listing  contains  a  reference line number, the 
  659. address and bytes assembled, and the original source input line.   If 
  660. an  input line causes more than 6 bytes to be output (e.g. a long FCC 
  661. directive), additional bytes (up to  64)  are  listed  on  succeeding 
  662. lines with no address preceding them.
  663.  
  664. The assembly listing may optionally contain a symbol table or a cross 
  665. reference table of all symbols appearing in the  program.  These  are 
  666. always  printed  at  the  end  of  the assembly listing if either the 
  667. symbol table or cross reference table options (Paragraph 4.8) are  in 
  668. effect. The symbol table contains the name of each symbol, along with 
  669. its defined value. The cross reference  table  additionally  contains 
  670. the  assembler-maintained  source  line  number of every reference to 
  671. every symbol. The format of the cross reference  table  is  shown  in 
  672. Appendix D.
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.                                  9
  706.  
  707.  
  708.  
  709.                                    Freeware Assemblers User's Manual
  710.  
  711.  
  712.                               CHAPTER 3
  713.                         RUNNING THE ASSEMBLERS
  714.  
  715.  
  716. 3.1   ASSEMBLER INVOCATION
  717.  
  718. The  Motorola  Freeware Assembly programs are named as*.exe where '*' 
  719. is any of 0, 1, 4, 5, 9, or 11 depending on  which  processor  family 
  720. you  wish  to assemble code for.  For example, to generate M6800 code 
  721. run the as0.exe program.  To generate M68HC05 code  run  the  as5.exe 
  722. program,  and  so  forth.   To  run the assembler enter the following 
  723. command line:
  724.  
  725.          as*   file1 (file2 . . . ) ( - option1 option2 . . . )
  726.  
  727. where file1, file2, etc are the names of the source files you wish to 
  728. assemble.  The source filenames may have extensions but the assembler 
  729. does not check for any particular extension ( however, do not use the
  730. .S19 extension since that is the extension of the object file created
  731. by the assembler.  Its creation would overwrite the source file when
  732. it is written to the disk).
  733.  
  734. The options are one or more of the following:
  735.  
  736.      l    enables output listing
  737.      no   disables output listing (default).
  738.      cre  enables the cross reference table generation
  739.      s    enables the symbol table generation
  740.      c    enables cycle counting
  741.      noc  disables cycle counting
  742.  
  743. The minus sign preceding the option should be separated from the last 
  744. file  name  by  a  space.  These options may also be indicated to the 
  745. assembler by the use of the OPT directive in the  source  file.   The 
  746. OPT directive is described in Paragraph 4.8.
  747.  
  748. The  object  file  created  is  written  to  disk  and given the name 
  749. 'FILENAME.S19' where 'FILENAME' is the name of the first source  file 
  750. specified  on  the command line.  Any errors and the optional listing 
  751. (if specified) are displayed on the screen.  The listing and/or error 
  752. messages  may be saved to a file for later examination or printing by 
  753. append an i/o redirection command to the command line.  On the PC i/o 
  754. redirection  is indicated with the greater-than ('>') symbol followed 
  755. by any new or existing file name.
  756.  
  757. Command line examples:
  758.  
  759. The command line
  760.  
  761.          as5 myfile
  762.  
  763. would run the M6805/68HC05 assembler on  the  source  file  'myfile'.  
  764. The object file would be written to 'myfile.s19' and any errors would 
  765. appear on the screen.
  766.  
  767.  
  768.                                  10
  769.  
  770.  
  771.  
  772.                                    Freeware Assemblers User's Manual
  773.  
  774.  
  775. The command line
  776.  
  777.          as9 test.asm nexttest.s -l
  778.  
  779. would run the M6809 assembler on  the  source  files  'test.asm'  and 
  780. 'nexttest.s'.  The object file would be written to 'test.s19' and any 
  781. errors and the assembly listing would appear on the screen.
  782.  
  783. The command line
  784.  
  785.          as9 test.asm nexttest.s -l cre s >test.lst
  786.  
  787. would run the M6809 assembler on  the  source  files  'test.asm'  and 
  788. 'nexttest.s'.   The  object  file  would be written to 'test.s19'.  A 
  789. listing would be  created  followed  by  a  symbol  table  and  cross 
  790. reference which would all be written to the file test.lst
  791. .
  792.  
  793. 3.2   ERROR MESSAGES
  794.  
  795. Error  diagnostic messages are placed in the listing file just before 
  796. the line containing the error.  The format of the error line is:
  797.  
  798.              Line_number:   Description of error
  799.  
  800.                                   or
  801.  
  802.              Line_number:   Warning ---- Description of error
  803.  
  804. Errors in pass one cause cancellation of pass two.   Warning  do  not 
  805. cause  cancellation  of  pass  two  but are indications of a possible 
  806. problem.  Error messages are meant to be self-explanatory.
  807.  
  808. If more than one file is being assembled, the file name precedes  the 
  809. error:
  810.  
  811.              File_name,Line_number:  Description of error
  812.  
  813. Some  errors  are classed as fatal and cause an immediate termination 
  814. of the assembly.  Generally this happens when a temporary file cannot 
  815. be created or is lost during assembly.
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.                                 11
  832.  
  833.  
  834.  
  835.                                    Freeware Assemblers User's Manual
  836.  
  837.  
  838.                               CHAPTER 4
  839.                          ASSEMBLER DIRECTIVES
  840.  
  841.  
  842. 4.1   INTRODUCTION
  843.  
  844. The  Assembler  directives  are instructions to the Assembler, rather 
  845. than instructions to be directly translated into  object  code.  This 
  846. chapter  describes the directives that are recognized by the Freeware 
  847. Assemblers. Detailed descriptions  of  each  directive  are  arranged 
  848. alphabetically. The notations used in this chapter are:
  849.  
  850.   ( )  Parentheses denote an optional element.
  851.  
  852.   XYZ  The names of the directives are printed in capital letters.
  853.  
  854.   <  >  The  element names are printed in lower case and contained in 
  855. angle brackets.  All elements outside of the angle brackets '<>' must 
  856. be  specified as-is. For example, the syntactical element (<number>,) 
  857. requires the comma to be specified if the optional  element  <number> 
  858. is  selected.  The  following  elements  are  used  in the subsequent 
  859. descriptions:
  860.  
  861.  
  862.      <comment>      A statement's comment field
  863.      <label>        A statement label
  864.      <expression>   An Assembler expression
  865.      <expr>         An Assembler expression
  866.      <number>       A numeric constant
  867.      <string>       A string of ASCII characters
  868.      <delimiter>    A string delimiter
  869.      <option>       An Assembler option
  870.      <symbol>       An Assembler symbol
  871.      <sym>          An Assembler symbol
  872.      <sect>         A relocatable program section
  873.      <reg list>     M6809 register list
  874.      <reg exp>      M6809 register expression
  875.  
  876.  
  877. In the following descriptions of the various directives, the  syntax, 
  878. or  format,  of  the directive is given first.  This will be followed 
  879. with the directive's description.
  880.  
  881. 4.2   BSZ - BLOCK STORAGE OF ZEROS
  882.  
  883.                    (<label>) BSZ <expression> (<comment>)
  884.  
  885. The BSZ directive causes the Assembler to allocate a block of  bytes. 
  886. Each  byte is assigned the initial value of zero. The number of bytes 
  887. allocated is given by the expression in the  operand  field.  If  the 
  888. expression  contains  symbols  that  are  either undefined or forward 
  889. referenced (i.e. the definition occurs later on in the file),  or  if 
  890. the expression has a value of zero, an error will be generated.
  891.  
  892.  
  893.  
  894.                                  12
  895.  
  896.  
  897.  
  898.                                    Freeware Assemblers User's Manual
  899.  
  900.  
  901. 4.3   EQU - EQUATE SYMBOL TO A VALUE
  902.  
  903.                    <label> EQU <expression> (<comment>)
  904.  
  905. The  EQU directive assigns the value of the expression in the operand 
  906. field to the label. The EQU directive assigns a value other than  the 
  907. program  counter to the label. The label cannot be redefined anywhere 
  908. else in the program.   The  expression  cannot  contain  any  forward 
  909. references or undefined symbols.  Equates with forward references are 
  910. flagged with Phasing Errors.
  911.  
  912. 4.4   FCB - FORM CONSTANT BYTE
  913.  
  914.          (<label>) FCB <expr>(,<expr>,...,<expr>) (<comment>)
  915.  
  916. The FCB directive may have one or more operands separated by  commas. 
  917. The  value  of each operand is truncated to eight bits, and is stored 
  918. in a single byte of the object program.  Multiple operands are stored 
  919. in  successive  bytes.  The  operand  may  be  a  numeric constant, a 
  920. character constant, a symbol, or an expression. If multiple  operands 
  921. are  present,  one or more of them can be null (two adjacent commas), 
  922. in which case a single  byte  of  zero  will  be  assigned  for  that 
  923. operand. An error will occur if the upper eight bits of the evaluated 
  924. operands' values are not all ones or all zeros.
  925.  
  926. 4.5   FCC - FORM CONSTANT CHARACTER STRING
  927.  
  928.          (<label>) FCC <delimiter><string><delimiter> (<comment>)
  929.  
  930. The FCC directive is used to store  ASCII  strings  into  consecutive 
  931. bytes  of  memory.   The  byte  storage begins at the current program 
  932. counter.  The label is assigned to the first byte in the string.  Any 
  933. of  the  printable  ASCII  characters can be contained in the string.  
  934. The string is specified between two identical delimiters which can be 
  935. any  printable  ASCII  character. The first non-blank character after 
  936. the FCC directive is used as the delimiter.
  937.  
  938. Example:
  939.  
  940.      LABEL1    FCC  , ABC,
  941.  
  942. assembles ASCII ABC at location LABEL1
  943.  
  944.  
  945. 4.6 FDB - FORM DOUBLE BYTE CONSTANT
  946.  
  947.          (<label>) FDB <expr>(,<expr>,...,<expr>) (<comment>)
  948.  
  949. The FDB directive may have one or more operands separated by  commas. 
  950. The  16-bit  value  corresponding  to each operand is stored into two 
  951. consecutive bytes of the object program.  The storage begins  at  the 
  952. current  program  counter.  The label is assigned to the first 16-bit 
  953. value. Multiple operands are stored in successive bytes.  The operand 
  954. may  be  a  numeric  constant,  a character constant, a symbol, or an 
  955. expression. If multiple operands are present, one or more of them can
  956.  
  957.                                  13
  958.  
  959.  
  960.  
  961.                                    Freeware Assemblers User's Manual
  962.  
  963.  
  964. be null (two adjacent commas), in which case two bytes of zeros  will 
  965. be assigned for that operand.
  966.  
  967. 4.7 FILL - FILL MEMORY
  968.  
  969.                    (<label>) FILL <expression>,<expression>
  970.  
  971. The  FILL  directive  causes  the  assembler to initialize an area of 
  972. memory with a constant value.  The first expression signifies the one 
  973. byte  value  to  be  placed  in  the memory and the second expression 
  974. indicates the total number of successive  bytes  to  be  initialized.  
  975. The  first  expression must evaluate to the range 0-255.  Expressions 
  976. cannot contain forward references or undefined symbols.
  977.  
  978. 4.8 OPT - ASSEMBLER OUTPUT OPTIONS
  979.  
  980.          OPT <option>(,<option>,...,<option>) (<comment>)
  981.  
  982. The OPT directive is used to control  the  format  of  the  Assembler 
  983. output.  The options are specified in the operand field, separated by 
  984. commas. All options have a default condition.  Some  options  can  be 
  985. initialized from the command line that invoked the Assembler, however 
  986. the options contained in the source file  take  precedence  over  any 
  987. entered  on  the  command  line.  In  the following descriptions, the 
  988. parenthetical inserts specify "DEFAULT", if the option is the default 
  989. condition.  All options must be entered in lower case.
  990.  
  991.   c  -  Enable  cycle counting in the listing.  The total cycle count 
  992. for that instruction will appear in the listing after  the  assembled 
  993. bytes and before the source code.
  994.  
  995.   cre  -  Print  a  cross  reference  table  at the end of the source 
  996. listing. This option, if used, must be  specified  before  the  first 
  997. symbol  in  the  source  program is encountered.  The cross reference 
  998. listing format may be found in Appendix D.
  999.  
  1000.    l - Print the listing from this point on.  A  description  of  the 
  1001. listing format can be found in Appendix D.
  1002.  
  1003.    noc - (DEFAULT) Disable cycle counting in the listing.  If the "c" 
  1004. option was used previously in the program,  this  option  will  cause 
  1005. cycle counting to cease until the next "OPT c" statement.
  1006.  
  1007.   nol  -  (DEFAULT)  Do not print the listing from this point on.  An 
  1008. "OPT l" can re-enable listing at a later point in the program.
  1009.  
  1010.    s - Print symbol table at end of source listing.  The symbol table 
  1011. format can be found in Appendix D.
  1012.  
  1013.  
  1014. 4.9 ORG - SET PROGRAM COUNTER TO ORIGIN
  1015.  
  1016.                    ORG <expression> (<comment>)
  1017.  
  1018. The  ORG directive changes the program counter to the value specified 
  1019. by the expression in the operand field. Subsequent statements are
  1020.  
  1021.                                  14
  1022.  
  1023.  
  1024.  
  1025.                                    Freeware Assemblers User's Manual
  1026.  
  1027.  
  1028. assembled into memory locations starting with the new program counter 
  1029. value.  If  no  ORG directive is encountered in a source program, the 
  1030. program counter is initialized to zero.  Expressions  cannot  contain 
  1031. forward references or undefined symbols.
  1032.  
  1033.  
  1034. 4.10 PAGE - TOP OF PAGE
  1035.  
  1036.                    PAGE
  1037.  
  1038. The  PAGE  directive causes the Assembler to advance the paper to the 
  1039. top of the next page. If no source listing  is  being  produced,  the 
  1040. PAGE  directive  will have no effect. The directive is not printed on 
  1041. the source listing.
  1042.  
  1043.  
  1044. 4.11 RMB - RESERVE MEMORY BYTES
  1045.  
  1046.                 (<label>) RMB <expression> (<comment>)
  1047.  
  1048. The RMB directive causes the location counter to be advanced  by  the 
  1049. value of the expression in the operand field. This directive reserves 
  1050. a block of memory the length of which in bytes is equal to the  value 
  1051. of the expression. The block of memory reserved is not initialized to 
  1052. any given value. The expression cannot contain any forward references 
  1053. or  undefined  symbols.  This directive is commonly used to reserve a 
  1054. scratchpad or table area for later use.
  1055.  
  1056. 4.12 ZMB - ZERO MEMORY BYTES  (same as BSZ)
  1057.  
  1058.                   (<label>) ZMB <expression> (<comment>)
  1059.  
  1060. The ZMB directive causes the Assembler to allocate a block of  bytes. 
  1061. Each  byte is assigned the initial value of zero. The number of bytes 
  1062. allocated is given by the expression in the  operand  field.  If  the 
  1063. expression  contains  symbols  that  are  either undefined or forward 
  1064. references, or if the expression has a value of zero, an  error  will 
  1065. be generated.
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.                                  15
  1086.  
  1087.  
  1088.  
  1089.                                    Freeware Assemblers User's Manual
  1090.  
  1091.  
  1092.                                APPENDIX A
  1093.                               CHARACTER SET
  1094.  
  1095.  
  1096. The  character  set recognized by the Freeware Assemblers is a subset 
  1097. of ASCII. The ASCII code  is  shown  in  the  following  figure.  The 
  1098. following characters are recognized by the Assembler:
  1099.  
  1100.         1.  The upper case letters A through Z and lower case letters 
  1101.             a through z.
  1102.  
  1103.         2. The digits 0 through 9.
  1104.  
  1105.         3. Five arithmetic operators:   +, -, *, / and %   (remainder
  1106.            after division).
  1107.  
  1108.         4. Three logical operators:  &, |, and ^.
  1109.  
  1110.         5. The special symbol characters:  underscore (_), period (.),
  1111.            and dollar sign ($).  Only the underscore and period may be
  1112.            used as the first character of a symbol.
  1113.  
  1114.         6. The characters used as prefixes for constants and
  1115.            addressing modes:
  1116.  
  1117.                #    Immediate addressing
  1118.                $    Hexadecimal constant
  1119.                &    Decimal constant
  1120.                @    Octal constant
  1121.                %    Binary constant
  1122.                '    ASCII character constant
  1123.  
  1124.         7. The characters used as suffixes for constants and
  1125.            addressing modes:
  1126.  
  1127.                ,X   Indexed addressing
  1128.                ,PCR M6809 indexed addressing
  1129.                ,S   M6809 indexed addressing
  1130.                ,U   M6809 indexed addressing
  1131.                ,Y   M6809 and M68HC11 indexed addressing
  1132.  
  1133.         8. Three separator characters:  space, carriage return, and
  1134.            comma.
  1135.  
  1136.         9. The character "*" to indicate comments.  Comments may
  1137.            contain any printable characters from the ASCII set.
  1138.  
  1139.        10. The  special  symbol  backslash  "\"  to   indicate   line 
  1140.            continuation.   When  the  assembler  encounters  the line 
  1141.            continuation character it fetches the next line  and  adds 
  1142.            it  to  the end of the first line.  This continues until a 
  1143.            line is seen which doesn't end with a backslash  or  until 
  1144.            the   system   maximum  buffer  size  has  been  collected 
  1145.            (typically greater or equal to 256).
  1146.  
  1147.  
  1148.                                 16
  1149.  
  1150.  
  1151.  
  1152.                                    Freeware Assemblers User's Manual
  1153.  
  1154.  
  1155.        11. For the M6809 Assembler,  the character  "<"  preceding an
  1156.            expression to  indicate  direct  addressing mode or  8-bit
  1157.            offset in indexed mode, and the character ">" preceding an
  1158.            expression to indicate extended addressing mode or  16-bit
  1159.            offset in indexed mode.
  1160.  
  1161.       12. For the M6809  Assembler,  the characters used to  indicate
  1162.           auto increment and auto decrement in the indexed mode:   +,
  1163.           ++, -, --.
  1164.  
  1165.  
  1166.  
  1167.  
  1168.                          ASCII CHARACTER CODES
  1169.  
  1170.  
  1171.            BITS 4 to 6 -- 0    1    2    3    4    5    6    7
  1172.            -----------    ------------------------------------- 
  1173.  
  1174.                      0    NUL  DLE  SP   0    @    P    `    p
  1175.                 B    1    SOH  DC1  :    1    A    Q    a    q
  1176.                 I    2    STX  DC2  !    2    B    R    b    r
  1177.                 T    3    ETX  DC3  #    3    C    S    c    s
  1178.                 S    4    EOT  DC4  $    4    D    T    d    t
  1179.                      5    ENQ  NAK  %    5    E    U    e    u
  1180.                 0    6    ACK  SYN  &    6    F    V    f    v
  1181.                      7    BEL  ETB  '    7    G    W    g    w
  1182.                 T    8    BS   CAN  (    8    H    X    h    x
  1183.                 O    9    HT   EM   )    9    I    Y    i    y
  1184.                      A    LF   SUB  *    :    J    Z    j    z
  1185.                 3    B    VT   ESC  +    ;    K    [    k    {
  1186.                      C    FF   FS   ,    <    L    \    l    ;
  1187.                      D    CR   GS   -    =    M    ]    m    }
  1188.                      E    SO   RS   .    >    N    ^    n    ~
  1189.                      F    S1   US   /    ?    O    _    o    DEL
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.                                 17
  1212.  
  1213.  
  1214.  
  1215.                                    Freeware Assemblers User's Manual
  1216.  
  1217.  
  1218.                               APPENDIX B
  1219.                            ADDRESSING MODES
  1220.  
  1221. B.1   M6800/M6801 ADDRESSING MODES.
  1222.  
  1223. INHERENT OR ACCUMULATOR ADDRESSING
  1224. The M6800 includes some instructions which require no operands. These 
  1225. instructions are self-contained and employ the inherent addressing or 
  1226. the accumulator addressing mode.
  1227.  
  1228.  
  1229. IMMEDIATE ADDRESSING
  1230. Immediate  addressing  refers  to  the  use  of  one  or two bytes of 
  1231. information that immediately follow the  operation  code  in  memory. 
  1232. Immediate addressing is indicated by preceding the operand field with 
  1233. the pound sign or number sign character (#). The expression following 
  1234. the  # will be assigned one or two bytes of storage, depending on the 
  1235. instruction.
  1236.  
  1237.  
  1238. RELATIVE ADDRESSING
  1239. Relative addressing is used by branch instructions. Branches can only 
  1240. be executed within the range -126 to +129 bytes relative to the first 
  1241. byte of the  branch  instruction.   For  this  mode,  the  programmer 
  1242. specifies  the branch address expression and places it in the operand 
  1243. field. The actual branch offset is calculated by  the  assembler  and 
  1244. put  into  the  second byte of the branch instruction.  The offset is 
  1245. the two's complement of the difference between the  location  of  the 
  1246. byte immediately following the branch instruction and the location of 
  1247. the destination of the branch.  Branches out of bounds are flagged as 
  1248. errors by the assembler.
  1249.  
  1250.  
  1251. INDEXED ADDRESSING
  1252. Indexed  addressing is relative to the index register. The address is 
  1253. calculated at the time of instruction execution by adding a  one-byte 
  1254. displacement  (in  the second byte of the instruction) to the current 
  1255. contents of the X register. Since no sign extension is  performed  on 
  1256. this  one-byte  displacement,  the offset cannot be negative. Indexed 
  1257. addressing  is  indicated  by  the  characters  ",X"  following   the 
  1258. expression  in the operand field. The special case of ",X", without a 
  1259. preceding expression, is treated as "0,X".
  1260.  
  1261.  
  1262. DIRECT AND EXTENDED ADDRESSING
  1263. Direct and extended addressing utilize one (direct) or two (extended) 
  1264. bytes  to  contain  the  address of the operand. Direct addressing is 
  1265. limited to the  first  256  bytes  of  memory.  Direct  and  extended 
  1266. addressing  are indicated by only having an expression in the operand 
  1267. field. Direct addressing will  be  used  by  the  Assembler  whenever 
  1268. possible.
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.                                 18
  1275.  
  1276.  
  1277.  
  1278.                                    Freeware Assemblers User's Manual
  1279.  
  1280.  
  1281. B.2   M6804/M68HC04 ADDRESSING MODES.
  1282.  
  1283. INHERENT OR ACCUMULATOR ADDRESSING
  1284. The M6800 includes some instructions which require no operands. These 
  1285. instructions are self-contained and employ the inherent addressing or 
  1286. the accumulator addressing mode.
  1287.  
  1288.  
  1289. IMMEDIATE ADDRESSING
  1290. Immediate  addressing  refers  to  the use of one byte of information 
  1291. that immediately follows the  operation  code  in  memory.  Immediate 
  1292. addressing is indicated by preceding the operand field with the pound 
  1293. sign or number sign character (#). The  expression  following  the  # 
  1294. will be assigned one byte of storage.
  1295.  
  1296.  
  1297. RELATIVE ADDRESSING
  1298. Relative addressing is used by branch instructions. Branches can only 
  1299. be executed within the range -15 to +16 bytes relative to  the  first 
  1300. byte  of  the  branch  instruction.   For  this  mode, the programmer 
  1301. specifies the branch address expression and places it in the  operand 
  1302. field.  The  actual  branch offset is calculated by the assembler and 
  1303. put into the second byte of the branch instruction.   The  offset  is 
  1304. the  two's  complement  of the difference between the location of the 
  1305. byte immediately following the branch instruction and the location of 
  1306. the destination of the branch.  Branches out of bounds are flagged as 
  1307. errors by the assembler.
  1308.  
  1309.  
  1310. DIRECT AND EXTENDED ADDRESSING
  1311. Direct and extended addressing utilize byte to contain the address of 
  1312. the  operand.  Direct addressing is limited to the first 256 bytes of 
  1313. memory.  Extended addressing concatenates the four  least-significant 
  1314. bits  of  the  opcode  with  the  byte following the opcode to form a 
  1315. 12-bit address. Direct and extended addressing are indicated by  only 
  1316. having an expression in the operand field.  Direct addressing will be 
  1317. used by the Assembler whenever possible.
  1318.  
  1319.  
  1320. SHORT DIRECT
  1321. Some opcodes allow 4 memory locations in data space  ram  ($80,  $81, 
  1322. $82,  and  $83  to  be  referenced as part of the opcode.  The opcode 
  1323. determines the data space RAM location, and the instruction  is  only 
  1324. one  byte.   The  X  and  Y  registers  are at locations $80 and $81, 
  1325. respectively.  An expression used with short direct  addressing  must 
  1326. not  be forward referenced (that is its definition must occur before, 
  1327. not after this point in the file) and must equate to the  range  $80- 
  1328. $83.
  1329.  
  1330.  
  1331. BIT SET AND CLEAR
  1332. In the bit set/clear addressing mode, the bit to be set or cleared is 
  1333. part of the opcode.  The byte  following  the  opcode  specifies  the 
  1334. direct  address  of  the byte which will have the bit set or cleared. 
  1335. Any bit in the  256 byte data space memory that can be written (with
  1336.  
  1337.  
  1338.                                 19
  1339.  
  1340.  
  1341.  
  1342.                                    Freeware Assemblers User's Manual
  1343.  
  1344.  
  1345. the exception of the data direction registers) can be set or  cleared 
  1346. with these two byte instructions.
  1347.  
  1348.  
  1349. BIT TEST AND BRANCH
  1350. The  bit  test  and  branch  addressing  mode is a combination of the 
  1351. direct addressing and relative addressing.  The bit to be tested, and 
  1352. it  condition  (set  or  clear), is included in the opcode.  The data 
  1353. space address of the  byte  to  be  tested  is  in  the  single  byte 
  1354. immediately  following  the opcode byte and follows direct addressing 
  1355. rules.  The third byte is  sign  extended  by  the  processor  during 
  1356. execution  to  form the 12-bit relative address which is added to the 
  1357. program counter if the condition is true.  This allows branches based 
  1358. on  any  readable  bit in the data space.  The branch span is -125 to 
  1359. +130 from the opcode address.  The branch target address is  used  by 
  1360. the  programmer  to  signify  the  relative  offset  -- the assembler 
  1361. calculates the offset value.  Branches out of bounds are  flagged  as 
  1362. errors by the assembler.
  1363.  
  1364.  
  1365. REGISTER INDIRECT
  1366. In  the register indirect mode, the operand is at the address in data 
  1367. space pointed to by the contents of one of the indirect registers,  X 
  1368. or  Y.   The  particular indirect register is encoded in bit 4 of the 
  1369. opcode by the assembler.  The assembler operand syntax  for  register 
  1370. indirect is
  1371.  
  1372.                     [<X> or <Y>]
  1373.  
  1374.  
  1375. MOVE IMMEDIATE
  1376. The MVI (move immediate) instruction has its own format:
  1377.  
  1378.          mvi   <expression 1>,#<expression 2>
  1379.  
  1380. where  <expression  1>  is a direct address and <expression 2> is the 
  1381. data value to be written.
  1382.  
  1383.  
  1384. MISCELLANEOUS SYNTAX ISSUES
  1385. The registers in  the  6804/HC6804  are  memory  locations  and  have 
  1386. addresses assigned to them.  The assembler has predefined
  1387.  
  1388.            a = A = $FF
  1389.            b = B = $80
  1390.            c = C = $81
  1391.  
  1392. This  also  means  that  for the '04 assembler clr x is equivalent to 
  1393. clrx since x is both a register and a memory location.
  1394.  
  1395. The '04 series has separate program and data  spaces.   There  is  no 
  1396. program memory in the range $10-$7F.  Bytes assembled into that range 
  1397. will go into the data space.
  1398.  
  1399.  
  1400.  
  1401.                                 20
  1402.  
  1403.  
  1404.  
  1405.                                    Freeware Assemblers User's Manual
  1406.  
  1407.  
  1408. B.3   M6805/68HC05 ADDRESSING MODES.
  1409.  
  1410. INHERENT OR ACCUMULATOR ADDRESSING
  1411. The M6805 includes some instructions which require no operands. These 
  1412. instructions  are  self-contained, and employ the inherent addressing 
  1413. or the accumulator addressing mode.
  1414.  
  1415.  
  1416. IMMEDIATE ADDRESSING
  1417. Immediate addressing refers to the use of  one  byte  of  information 
  1418. that  immediately  follows  the  operation  code in memory. Immediate 
  1419. addressing is indicated by preceding the operand field with the pound 
  1420. sign  or  number  sign  character (#). The expression following the # 
  1421. will be assigned one byte of storage.
  1422.  
  1423.  
  1424. RELATIVE ADDRESSING
  1425. Relative addressing is used by branch instructions. Branches can only 
  1426. be executed within the range -126 to +129 bytes relative to the first 
  1427. byte of  the  branch  instruction.  For  this  mode,  the  programmer 
  1428. specifies  the branch address expression and places it in the operand 
  1429. field. The actual branch offset is calculated by  the  assembler  and 
  1430. put  into  the  second byte of the branch instruction.  The offset is 
  1431. the two's complement of the difference between the  location  of  the 
  1432. byte immediately following the branch instruction and the location of 
  1433. the destination of the branch.  Branches out of bounds are flagged as 
  1434. errors by the assembler.
  1435.  
  1436.  
  1437. INDEXED ADDRESSING
  1438. Indexed  addressing is relative to the index register. The address is 
  1439. calculated at the time of instruction execution by adding a  one-  or 
  1440. two-byte  displacement to the current contents of the X register. The 
  1441. displacement immediately follows the operation code  in  memory.   If 
  1442. the  displacement  is zero, no offset is added to the index register.  
  1443. In this case, only the operation code resides in  memory.   Since  no 
  1444. sign  extension  is  performed on a one-byte displacement, the offset 
  1445. cannot be negative. Indexed addressing is indicated by the characters 
  1446. ",X" following the expression in the operand field.  The special case 
  1447. of ",X", without a preceding expression, is treated  as  "0,X".  Some 
  1448. instructions do not allow a two-byte displacement.
  1449.  
  1450.  
  1451. DIRECT AND EXTENDED ADDRESSING
  1452. Direct and extended addressing utilize one (direct) or two (extended) 
  1453. bytes to contain the address of the  operand.  Direct  addressing  is 
  1454. limited  to  the  first  256  bytes  of  memory.  Direct and extended 
  1455. addressing are indicated by only having an expression in the  operand 
  1456. field.  Some  instructions  do not allow extended addressing.  Direct 
  1457. addressing will be used by the Macro Assembler whenever possible.
  1458.  
  1459.  
  1460. BIT SET OR CLEAR
  1461. The addressing mode used for this  type  of  instruction  is  direct, 
  1462. although the format of the operand field is different from the direct 
  1463. addressing mode described above. The operand takes the form
  1464.  
  1465.                                 21
  1466.  
  1467.  
  1468.  
  1469.                                    Freeware Assemblers User's Manual
  1470.  
  1471.  
  1472. <expression 1>, <expression 2>. <expression 1> indicates which bit is 
  1473. to be set or cleared.  It must be an absolute expression in the range 
  1474. 0-7. It is used in generating the operation code.  <expression 2>  is 
  1475. handled  as  a  direct  address,  as  described above.  Since the bit 
  1476. manipulation address is direct, only the first 256 locations  may  be 
  1477. operated on by bit manipulation operations.
  1478.  
  1479.  
  1480. BIT TEST AND BRANCH
  1481. This  combines  two addressing modes: direct and relative. The format 
  1482. of the operand is: <expression 1>, <expression  2>,  <expression  3>. 
  1483. <expression  1>  and <expression 2> are handled in the same manner as 
  1484. described above in "bit set or clear".  <expression  3>  is  used  to 
  1485. generate   a  relative  address,  as  described  above  in  "relative 
  1486. addressing".
  1487.  
  1488.  
  1489. B.4  M6809 ADDRESSING MODES.
  1490.  
  1491. INHERENT OR ACCUMULATOR ADDRESSING
  1492. The M6809 includes some instructions which require no operands. These 
  1493. instructions  are  self-contained, and employ the inherent addressing 
  1494. or the accumulator addressing mode.
  1495.  
  1496.  
  1497. IMMEDIATE ADDRESSING
  1498. Immediate addressing refers to  the  use  of  one  or  two  bytes  of 
  1499. information  that  immediately  follow  the operation code in memory. 
  1500. Immediate addressing is indicated by preceding the operand field with 
  1501. the  pound  sign  or  number  sign  (#)  -- i.e., #<expression>.  The 
  1502. expression following the # will be  assigned  one  or  two  bytes  of 
  1503. storage,  depending  on the instruction. All instructions referencing 
  1504. the accumulator "A" or "B", or the condition code register "CC", will 
  1505. generate  a one-byte immediate value. Also, immediate addressing used 
  1506. with the PSHS, PULS, PSHU, and PULU instructions generates a one-byte 
  1507. immediate  value.  Immediate  operands used in all other instructions 
  1508. generate a two-byte value.
  1509.  
  1510. The register list operand does not take the  form  #<expression>  but 
  1511. still  generates  one byte of immediate data. The form of the operand 
  1512. is:
  1513.  
  1514.                             R1,R2,...,Rn
  1515.  
  1516. where Ri (i=1 to n) is one of the symbols A, B, CC, D, DP, PC, S,  U, 
  1517. X  or  Y.  The  number  and  type  of  symbols vary, depending on the 
  1518. specific instruction.
  1519.  
  1520. For the instructions PSHS, PULS, PSHU, and PULU,  any  of  the  above 
  1521. register  names  may  be  included  in  the  register  list. The only 
  1522. restriction is that "U" cannot be specified with PSHU  or  PULU,  and 
  1523. "S"  cannot  be  specified  with PSHS or PULS. The one-byte immediate 
  1524. value assigned to the operand is calculated by the assembler  and  is 
  1525. determined  by the registers specified. Each register name causes the 
  1526. assembler to set a bit in the immediate byte as follows:
  1527.  
  1528.  
  1529.                                  22
  1530.  
  1531.  
  1532.  
  1533.                                    Freeware Assemblers User's Manual
  1534.  
  1535.  
  1536.           Register  Bit
  1537.           --------  ---
  1538.  
  1539.             PC      7
  1540.             U,S     6
  1541.             Y       5
  1542.             X       4
  1543.             DP      3
  1544.             B,D     2
  1545.             A,D     1
  1546.             CC      0
  1547.  
  1548.  
  1549. For the instructions EXG and TFR, exactly two of the  above  register 
  1550. names must be included in the register list. The other restriction is 
  1551. the size of the registers specified. For the EXG instruction, the two 
  1552. registers  must  be  the  same size. For the TFR instruction, the two 
  1553. registers must be the same  size,  or  the  first  can  be  a  16-bit 
  1554. register  and  the  second  an  8-bit register. In the case where the 
  1555. transfer is from a 16-bit register to an 8-bit  register,  the  least 
  1556. significant  8  bits  are transferred.  The 8-bit registers are A, B, 
  1557. CC, and DP.  The 16-bit registers are D, PC, S, U,  X,  and  Y.   The 
  1558. one-byte  immediate value assigned to the operand by the assembler is 
  1559. determined by the register names. The most significant four  bits  of 
  1560. the  immediate byte contain the value of the first register name; the 
  1561. least significant four bits contain the value of the second register, 
  1562. as shown by the following table:.
  1563.  
  1564.  
  1565.           Register  Value (hex)
  1566.           --------  -----------
  1567.  
  1568.              D          0
  1569.              X          1
  1570.              Y          2
  1571.              U          3
  1572.              S          4
  1573.              PC         5
  1574.              A          8
  1575.              B          9
  1576.              CC         A
  1577.              DP         B
  1578.  
  1579.  
  1580. RELATIVE  ADDRESSING
  1581. Relative  addressing  is  used  by branch instructions. There are two 
  1582. forms of the  branch  instruction.  The  short  branch  can  only  be 
  1583. executed  within  the  range -126 to +129 bytes relative to the first 
  1584. byte of  the  branch  instruction.  For  this  mode,  the  programmer 
  1585. specifies  the branch address expression and places it in the operand 
  1586. field. The actual branch offset is calculated by  the  assembler  and 
  1587. put  into  the second byte of the branch instruction. The long branch 
  1588. can  execute  in  the  full  range  of  addressing   from   0000-FFFF 
  1589. (hexadecimal)  because  a  two-  byte  offset  is  calculated  by the 
  1590. assembler and put into the operand field of the  branch  instruction.  
  1591. The  offset  is  the  two's  complement of the difference between the 
  1592. location of the byte immediately 
  1593.  
  1594.                                 23
  1595.  
  1596.  
  1597.  
  1598.                                    Freeware Assemblers User's Manual
  1599.  
  1600.  
  1601. following the branch instruction and the location of the  destination 
  1602. of the branch.
  1603.  
  1604.  
  1605. DIRECT AND EXTENDED ADDRESSING
  1606. Direct and extended addressing utilize one (direct) or two (extended) 
  1607. bytes to contain the address of  the  operand.  Direct  and  extended 
  1608. addressing  are indicated by having only an expression in the operand 
  1609. field (i.e., <expression>). Direct addressing will be  used  whenever 
  1610. possible.
  1611.  
  1612. Regardless  of  the criteria described above, it is possible to force 
  1613. the Assembler to use the direct  addressing  mode  by  preceding  the 
  1614. operand with the "<" character. Similarly, extended addressing can be 
  1615. forced by preceding the operand with the ">"  character.   These  two 
  1616. operand forms are: <<expression> and ><expression>.
  1617.  
  1618.  
  1619. INDEXED ADDRESSING
  1620. Indexed  addressing  is  relative  to one of the index registers. The 
  1621. general form is <expression>,R. The address is calculated at the time 
  1622. of  instruction  execution by adding the value of <expression> to the 
  1623. current contents of the index register. The  other  general  form  is 
  1624. [<expression>,R].   In  this indirect form, the address is calculated 
  1625. at the time of instruction execution by first  adding  the  value  of 
  1626. <expression>  to the current contents of the index register, and then 
  1627. retrieving the two bytes from the calculated address  and  address+1. 
  1628. This  two-byte value is used as the effective address of the operand. 
  1629. The allowable forms of indexed addressing are  described  below.   In 
  1630. the  description  below, R refers to one of the index registers S, U, 
  1631. X, or Y.
  1632.  
  1633. The accumulator offset mode allows one  of  the  accumulators  to  be 
  1634. specified instead of an <expression>. Valid forms are:.
  1635.  
  1636.                    <acc>,R and [<acc>,R]
  1637.  
  1638. where  <acc>  is  one  of  the  accumulators  A,  B,  or D. This form 
  1639. generates a one-byte operand (post-byte only). When accumulator A  or 
  1640. B  is  specified,  sign extension occurs prior to adding the value in 
  1641. the accumulator to the index register.
  1642.  
  1643. The valid forms for the automatic increment/decrement mode are  shown 
  1644. below.  For each row, the three entries shown are equivalent.
  1645.  
  1646.  
  1647.                R+       ,R+      0,R+
  1648.                -R       ,-R      0,-R
  1649.                R++      ,R++     0,R++
  1650.                --R      ,--R     0,--R
  1651.                [R++]    ,R++]    [0,R++]
  1652.                [--R]    [,--R]   [0,--R]
  1653.  
  1654.  
  1655. In  this  form,  the only valid expression is 0. Like the accumulator 
  1656. offset mode, this form generates a one-byte operand (post-byte only).
  1657.  
  1658.                                 24
  1659.  
  1660.  
  1661.  
  1662.                                    Freeware Assemblers User's Manual
  1663.  
  1664.  
  1665. The valid forms for the expression offset mode are:
  1666.  
  1667.  
  1668.                R       ,R     <expression>,R
  1669.                [R]     [,R]   [<expression>,R]
  1670.                <R      <,R    <<expression>,R
  1671.                <[R]    <[,R]  <[<expression>,R]
  1672.                >R      >,R    ><expression>,R
  1673.                >[R]    >[,R]  >[<expression>,R]
  1674.  
  1675.  
  1676. The  "<"  and  ">"  characters  force  an  8-   or   16-bit   offset, 
  1677. respectively, and are described below. If no expression is specified, 
  1678. or if an expression with a value  of  zero  is  specified,  only  the 
  1679. postbyte  of  the operand is generated. If an expression with a value 
  1680. in the range -16 to +15 is specified without indirection, a one- byte 
  1681. operand  is  generated which contains the expression's value, as well 
  1682. as the index register indicator. At execution time, the  expression's 
  1683. value  is  expanded to 16 bits with sign extension before being added 
  1684. to the index register.
  1685.  
  1686. All other forms will generate a post-byte, as well as either  a  one- 
  1687. or  two-byte  offset  which contains the value of the expression. The 
  1688. size of the offset  is  determined  by  the  type  and  size  of  the 
  1689. expression.  Expressions  with  values  in  the  range  -128  to +127 
  1690. generate an 8-bit offset.  All other cases will result  in  a  16-bit 
  1691. offset  being  generated.  In  the  case  where  an  8-bit  offset is 
  1692. generated, the value is expanded to 16 bits with  sign  extension  at 
  1693. execution time.
  1694.  
  1695. Regardless  of  the criteria described above, it is possible to force 
  1696. the Assembler to generate an 8-bit offset by  preceding  the  operand 
  1697. with  the  "<" character. Similarly, a 16-bit offset can be forced by 
  1698. preceding the operand with the ">" character.
  1699.  
  1700. If the relative address calculated is not in the range -128 to  +127, 
  1701. or  if  the  expression  references  a  symbol  that has not yet been 
  1702. defined, a two-byte offset is generated after the post-byte.  A  one- 
  1703. byte offset is generated if the relative address is in the range -128 
  1704. to +127.
  1705.  
  1706. Like the expression offset mode, a one-byte offset can be  forced  by 
  1707. preceding  the operand with a "<".  A ">" forces a two-byte offset. A 
  1708. byte overflow error is generated if a one-byte offset is forced  when 
  1709. the relative address is not in the range -12 8 to +127.
  1710.  
  1711. The extended indirect mode has the form:
  1712.  
  1713.                      [<expression>]
  1714.  
  1715. Although  extended  indirect  is  a logical extension of the extended 
  1716. addressing mode, this mode is implemented using an  encoding  of  the 
  1717. postbyte  under  the indexed addressing mode.  A post-byte and a two- 
  1718. byte offset which contains the value of the expression is generated.
  1719.  
  1720.  
  1721.                                 25
  1722.  
  1723.  
  1724.  
  1725.                                    Freeware Assemblers User's Manual
  1726.  
  1727.  
  1728. B.5  M68HC11 ADDRESSING MODES.
  1729.  
  1730. PREBYTE
  1731. The number of combinations of instructions and addressing  modes  for 
  1732. the  68HC11  is  larger  than that possible to be encoded in an 8-bit 
  1733. word (256 combinations).  To expand the opcode map,  certain  opcodes 
  1734. ($18,  $1A, and $CD) cause the processor to fetch the next address to 
  1735. find the actual instruction.  These opcodes are known as prebytes and 
  1736. are  inserted  automatically  by the assembler for those instructions 
  1737. that require it.l  In  general  the  instructions  contained  in  the 
  1738. alternate maps are those involving the Y register or addressing modes 
  1739. that involve the Y index register.   Thus  the  programmer  make  the 
  1740. tradeoff  between  the convenience of using the second index register 
  1741. and the additional time and code space used by the prebyte.
  1742.  
  1743.  
  1744. INHERENT OR ACCUMULATOR ADDRESSING
  1745. The M68HC11 includes some instructions  which  require  no  operands. 
  1746. These  instructions  are  self-contained,  and  employ  the  inherent 
  1747. addressing or the accumulator addressing mode.
  1748.  
  1749.  
  1750. IMMEDIATE ADDRESSING
  1751. Immediate addressing refers to the  use  of  one  or  more  bytes  of 
  1752. information  that  immediately  follow  the operation code in memory. 
  1753. Immediate addressing is indicated by preceding the operand field with 
  1754. the pound sign or number sign character (#). The expression following 
  1755. the # will be assigned one byte of storage.
  1756.  
  1757.  
  1758. RELATIVE ADDRESSING
  1759. Relative addressing is used by branch instructions. Branches can only 
  1760. be executed within the range -126 to +129 bytes relative to the first 
  1761. byte of  the  branch  instruction.  For  this  mode,  the  programmer 
  1762. specifies  the branch address expression and places it in the operand 
  1763. field. The actual branch offset is calculated by  the  assembler  and 
  1764. put  into  the  second byte of the branch instruction.  The offset is 
  1765. the two's complement of the difference between the  location  of  the 
  1766. byte immediately following the branch instruction and the location of 
  1767. the destination of the branch.  Branches out of bounds are flagged as 
  1768. errors by the assembler.
  1769.  
  1770.  
  1771. INDEXED ADDRESSING
  1772. Indexed  addressing  is  relative  one of the index registers X or Y.  
  1773. The address is calculated at the time  of  instruction  execution  by 
  1774. adding  a  one-byte  displacement  to  the  current contents of the X 
  1775. register. The displacement immediately follows the operation code  in 
  1776. memory.   If  the  displacement  is  zero,  zero  resides in the byte 
  1777. following the opcode. Since no  sign  extension  is  performed  on  a 
  1778. one-byte   displacement,  the  offset  cannot  be  negative.  Indexed 
  1779. addressing  is  indicated  by  the  characters  ",X"  following   the 
  1780. expression in the operand field.  The special case of ",X", without a 
  1781. preceding expression, is treated as "0,X".
  1782.  
  1783.  
  1784.                                 26
  1785.  
  1786.  
  1787.  
  1788.                                    Freeware Assemblers User's Manual
  1789.  
  1790.  
  1791. DIRECT AND EXTENDED ADDRESSING
  1792. Direct and extended addressing utilize one (direct) or two (extended) 
  1793. bytes  to  contain  the  address of the operand. Direct addressing is 
  1794. limited to the first  256  bytes  of  memory.   Direct  and  extended 
  1795. addressing  are indicated by only having an expression in the operand 
  1796. field.  Direct addressing will be  used  by  the  Assembler  whenever 
  1797. possible.
  1798.  
  1799.  
  1800. BIT(S) SET OR CLEAR
  1801. The  addressing  mode  used  for  this type of instruction is direct, 
  1802. although the format of the operand field is different from the direct 
  1803. addressing   mode   described  above.  The  operand  takes  the  form 
  1804. <expression 1> <expression 2> where the two expressions are separated 
  1805. by  a blank.  <expression 1> signifies the operand address and may be 
  1806. either a direct or an indexed address.   When  the  address  mode  is 
  1807. indexed, <expression 1> is followed by ',R' where R is either X or Y. 
  1808. This allows bit  manipulation  instructions  to  operate  across  the 
  1809. complete  64K  address  map.   <expression  2> is the mask byte.  The 
  1810. bit(s)  to  be  set  or  cleared  are  indicated  by  ones   in   the 
  1811. corresponding location(s) in the mask byte.  The mask byte must be an 
  1812. expression in the range 0-255 and is encoded by the programmer.
  1813.  
  1814.  
  1815. BIT TEST AND BRANCH
  1816. This combines two addressing modes: direct or indexed  and  relative. 
  1817. The   format  of  the  operand  is:  <expression  1>  <expression  2> 
  1818. <expression  3>  where  the  expressions  are  separated  by  blanks. 
  1819. <expression 1> identifies the operand an may indicate either a direct 
  1820. or indexed  address.   Indexed  addresses  are  signified  with  ',R' 
  1821. following  the expression where R is either X or Y. <expression 2> is 
  1822. the mask byte.  The bit(s) to be set or cleared are indicated by ones 
  1823. in  the  corresponding  location(s)  in the mask byte.  The mask byte 
  1824. must be an expression in the  range  0-255  and  is  encoded  by  the 
  1825. programmer. <expression 3> is used to generate a relative address, as 
  1826. described above in "relative addressing".
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.                                 27
  1848.  
  1849.  
  1850.  
  1851.                                    Freeware Assemblers User's Manual
  1852.  
  1853.  
  1854.                                APPENDIX C
  1855.                             DIRECTIVE SUMMARY
  1856.  
  1857.  
  1858. A complete description of all directives appears in Chapter 4.
  1859.  
  1860.  
  1861. ASSEMBLY CONTROL
  1862.  
  1863.      ORG  Origin program counter
  1864.  
  1865. SYMBOL DEFINITION
  1866.  
  1867.      EQU  Assign permanent value
  1868.  
  1869. DATA DEFINITION/STORAGE ALLOCATION
  1870.  
  1871.      BSZ  Block storage of zero; single bytes
  1872.  
  1873.      FCB  Form constant byte
  1874.  
  1875.      FCC  Form constant character string
  1876.  
  1877.      FDB  Form constant double byte
  1878.  
  1879.      FILL Initialize a block of memory to a constant
  1880.  
  1881.      RMB  Reserve memory; single bytes
  1882.  
  1883.      ZMB  Zero Memory Bytes; same and BSZ
  1884.  
  1885.  
  1886.  LISTING CONTROL
  1887.  
  1888.      OPT c     Enable cycle counting
  1889.  
  1890.      OPT cre   Print cross reference table
  1891.  
  1892.      OPT l     Print source listing from this point
  1893.  
  1894.      OPT nol   Inhibit printing of source listing from this point
  1895.  
  1896.      OPT s     Print symbol table
  1897.  
  1898.      PAGE Print subsequent statements on top of next page
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.                                 28
  1911.  
  1912.  
  1913.  
  1914.                                    Freeware Assemblers User's Manual
  1915.  
  1916.  
  1917.                               APPENDIX D
  1918.                         ASSEMBLER LISTING FORMAT
  1919.  
  1920.  
  1921. The Assembler listing has the following format:
  1922.  
  1923.     LINE#   ADDR  OBJECT CODE BYTES       [ # CYCLES]  SOURCE LINE
  1924.  
  1925. The LINE# is a 4 digit decimal number printed as a  reference.   This 
  1926. reference number is used in the cross reference.  The ADDR is the hex 
  1927. value of the address for the first byte of the object code  for  this 
  1928. instruction.   The OBJECT CODE BYTES are the assembled object code of 
  1929. the source line in hex.  If an source line causes more than  6  bytes 
  1930. to be output (e.g. a long FCC directive), additional bytes (up to 64) 
  1931. are listed on succeeding lines with no address preceding them.
  1932.  
  1933. The # CYCLES will only appear in the listing if the "c" option is  in 
  1934. effect.   It  is enclosed in brackets which helps distinguish it from 
  1935. the source listing.  The SOURCE LINE is reprinted  exactly  from  the 
  1936. source program, including labels.
  1937.  
  1938. The symbol table has the following format:
  1939.  
  1940.      SYMBOL    ADDR
  1941.  
  1942. The  symbol  is  taken  directly  from  the label field in the source 
  1943. program.  The  ADDR  is  the  hexadecimal  address  of  the  location 
  1944. referenced by the symbol.
  1945.  
  1946. The cross reference listing has the following format:
  1947.  
  1948.      SYMBOL   ADDR   *LOC1 LOC2 LOC3 ...
  1949.  
  1950. The  SYMBOL and ADDR are the same as above. The * indicates the start 
  1951. of the line reference numbers.  The LOCs are the decimal line numbers 
  1952. of the assembler listing where the label occurs.
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.                                 29
  1974.  
  1975.  
  1976.  
  1977.                                    Freeware Assemblers User's Manual
  1978.  
  1979.  
  1980.                               APPENDIX E
  1981.                          S-RECORD INFORMATION
  1982.  
  1983.  
  1984. E.1   INTRODUCTION
  1985.  
  1986. The  S-record  output  format encodes program and data object modules 
  1987. into a printable (ASCII) format.  This allows viewing of  the  object 
  1988. file  with  standard  tools  and  allows  display of the module while 
  1989. transferring from one computer to the next or during loads between  a 
  1990. host  and  target.  The S-record format also includes information for 
  1991. use in error checking to insure the integrity of data transfers.
  1992.  
  1993.  
  1994. E.2   S-RECORD CONTENT
  1995.  
  1996. S-Records are character strings made of several fields which identify 
  1997. the  record  type,  record  length,  memory  address,  code/data, and 
  1998. checksum.  Each byte of binary  data  is  encoded  as  a  2-character 
  1999. hexadecimal number: the first character representing the high-order 4 
  2000. bits, and the second the low-order 4 bits of the byte.
  2001.  
  2002. The 5 fields which comprise an S-record are:
  2003.  
  2004.       TYPE  RECORD LENGTH   ADDRESS   CODE/DATA  CHECKSUM
  2005.  
  2006. The fields are defined as follows:
  2007.  
  2008.      FIELD      CHARACTERS                   CONTENTS
  2009.      -----      ----------                   --------
  2010.      Type           2         S-record type - S1, S9, etc.
  2011.  
  2012.      Record         2         The count of the character pairs in the
  2013.      length                   record,  excluding  the type and record
  2014.                               length.
  2015.  
  2016.      Address      4, 6,       The 2-,  3-, or 4-byte address at which
  2017.                   or 8        the  data  field  is  to be loaded into
  2018.                               memory.
  2019.  
  2020.      Code/data    0-2n        From  0  to n bytes of executable code,
  2021.                               memory  loadable  data,  or descriptive
  2022.                               information.
  2023.  
  2024.      Checksum       2         The least significant byte of the one's
  2025.                               complement  of the  sum  of  the values
  2026.                               represented by the pairs of  characters
  2027.                               making up the  record length,  address,
  2028.                               and the code/data fields.
  2029.  
  2030. Each record may be terminated with a CR/LF/NULL.
  2031.  
  2032.  
  2033. E.3   S-RECORD TYPES
  2034.  
  2035. Eight types of s-records have been defined to accommodate various
  2036.  
  2037.                                 30
  2038.  
  2039.  
  2040.  
  2041.                                    Freeware Assemblers User's Manual
  2042.  
  2043.  
  2044. encoding,  transportation,  and   decoding   needs.    The   Freeware 
  2045. assemblers use only two types, the S1 and S9:
  2046.  
  2047.      S1   A record containing code/data and the 2-byte
  2048.           address at which the code/data is to reside.
  2049.  
  2050.      S9   A termination record for a block of S1 records. The address
  2051.           field  may  optionally  contain  the  2-byte address of the
  2052.           instruction to  which control  is to  be  passed.   If  not
  2053.           specified,  the first entry point specification encountered
  2054.           in  the  object  module  input  will  be used.  There is no
  2055.           code/data field.
  2056.  
  2057. E.4   S-RECORD EXAMPLE
  2058.  
  2059. The following is a typical S-record module:
  2060.  
  2061.           S1130000285F245F2212226A000424290008237C2A
  2062.           S11300100002000800082629001853812341001813
  2063.           S113002041E900084E42234300182342000824A952
  2064.           S107003000144ED492
  2065.           S9030000FC
  2066.  
  2067. The module consists of four code/data records and an S9 termination
  2068. record.
  2069.  
  2070. The first S1 code/data record is explained as follows:
  2071.  
  2072.      S1   S-record type S1, indicating a code/data record to be
  2073.           loaded/verified at a 2-byte address.
  2074.  
  2075.      13   Hex 13 (decimal 19), indicating 19 character pairs,
  2076.           representing 19 bytes of  binary data, follow.
  2077.  
  2078.      00   Four-character  2-byte  address  field:   hex address  0000,
  2079.           indicates location where the following data is to be loaded.
  2080.  
  2081.      The next  16 character pairs are the  ASCII  bytes of the actual
  2082.      program code/data
  2083.  
  2084.      2A   Checksum of the first S1 record.
  2085.  
  2086. The  second  and  third  S1  code/data  records each also contain $13 
  2087. character  pairs  and  are  ended  with  checksums.   The  fourth  S1 
  2088. code/data record contains 7 character pairs.
  2089.  
  2090. The S9 termination record is explained as follows:
  2091.  
  2092.      S9   S-record type S9, indicating a termination record.
  2093.  
  2094.      03   Hex 03, indicating three character pairs (3 bytes) to
  2095.           follow.
  2096.  
  2097.      00   Four character 2-byte address field, zeroes.
  2098.      00
  2099.  
  2100.      FC   Checksum of  S9 record.
  2101.  
  2102.                                 31
  2103.